package com.nwpu.coursesupport.view.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.nwpu.coursesupport.controller.AbstractController;
import com.nwpu.coursesupport.entity.bean.JSONResult;

@Controller
@RequestMapping("/shareTaskView")
public class ShareTaskViewController extends AbstractController{

	//学生
	@RequestMapping("/slistData")
	public String slistData(@RequestParam("lessonId")int id,HttpServletRequest request){
		JSONResult rst=invokeService("shareTaskView", "list", "{\"id\":\"" + id + "\"}");
		request.setAttribute("data", this.parseData(rst));
		return "/stupage/lessonShare";
	}
	
	@RequestMapping("/ajaxSListData")
	@ResponseBody
	public JSONResult ajaxSListData(@RequestParam("data")String data){
		JSONResult rst=invokeService("shareTaskView", "ajaxTList", data);
		return rst;
	}
	//老师
	@RequestMapping("/tlistData")
	public String tlistData(@RequestParam("lessonId")int id,HttpServletRequest request){
		JSONResult rst=invokeService("shareTaskView", "list", "{\"id\":\"" + id + "\"}");
		request.setAttribute("data", this.parseData(rst));
		return "/teapage/classroomShare";
	}
	
	@RequestMapping("/ajaxTListData")
	@ResponseBody
	public JSONResult ajaxTListData(@RequestParam("data")String data){
		JSONResult rst=invokeService("shareTaskView", "ajaxTList", data);
		return rst;
	}
	
	@RequestMapping("/detail")
	public String detail(@RequestParam("id")int id,HttpServletRequest request){
		JSONResult rst=invokeService("shareTaskView", "detail", "{\"id\":\"" + id + "\"}");
		request.setAttribute("data", this.parseData(rst));
		return "";
	}
	
	@RequestMapping("/ajaxDetail")
	@ResponseBody
	public JSONResult ajaxDetail(@RequestParam("id")int id){
		JSONResult rst=invokeService("shareTaskView", "detail", "{\"id\":\"" + id + "\"}");
		return rst;
	}
}
